package com.boot.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.boot.entity.Topic;
import com.boot.mapper.TopicMapper;

@Controller
public class TopicController {
    @Autowired
    TopicMapper mapper;
	//添加评论
	@RequestMapping("addTopic")
	public @ResponseBody String addTopic(String topicTitle) {
		Topic topic = new Topic();
		topic.setTime(new Date());
		topic.setUsername("老夏");
		topic.setTopicTitle(topicTitle);
		try {
		mapper.insertTopic(topic);
		return "添加成功";
		}
		catch(Exception e) {
			e.printStackTrace();
			return "添加失败";
		}
		
		
	}
	
}
